/***********************************************************************
 * Module:  PoslovnaGodina.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class PoslovnaGodina
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class PoslovnaGodina implements Serializable {
	
	protected Integer id;
	protected short godina;
	protected boolean zakljucena;
	protected int verzija;

	protected Collection<MagacinskaKartica> magacinskeKartice;

	public Collection<MagacinskaKartica> getMagacinskeKartice() {
		if (magacinskeKartice == null)
			magacinskeKartice = new HashSet<MagacinskaKartica>();
		
		return magacinskeKartice;
	}

	public Iterator<MagacinskaKartica> getIteratorMagacinskeKartice() {
		if (magacinskeKartice == null)
			magacinskeKartice = new HashSet<MagacinskaKartica>();
		
		return magacinskeKartice.iterator();
	}

	public void setMagacinskeKartice(
			Collection<MagacinskaKartica> newMAGACINSKA_KARTICA) {
		removeAllMagacinskeKartice();
		for (Iterator<MagacinskaKartica> iter = newMAGACINSKA_KARTICA.iterator(); iter.hasNext();)
			addMagacinskaKartica((MagacinskaKartica) iter.next());
	}

	public void addMagacinskaKartica(MagacinskaKartica newMagacinskaKartica) {
		if (newMagacinskaKartica == null)
			return;
		if (this.magacinskeKartice == null)
			this.magacinskeKartice = new HashSet<MagacinskaKartica>();
		if (!this.magacinskeKartice.contains(newMagacinskaKartica))
			this.magacinskeKartice.add(newMagacinskaKartica);
	}

	public void removeMagacinskaKartica(MagacinskaKartica oldMagacinskaKartica) {
		if (oldMagacinskaKartica == null)
			return;
		if (this.magacinskeKartice != null)
			if (this.magacinskeKartice.contains(oldMagacinskaKartica))
				this.magacinskeKartice.remove(oldMagacinskaKartica);
	}

	public void removeAllMagacinskeKartice() {
		if (magacinskeKartice != null)
			magacinskeKartice.clear();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public short getGodina() {
		return godina;
	}

	public void setGodina(short godina) {
		this.godina = godina;
	}

	public boolean isZakljucena() {
		return zakljucena;
	}

	public void setZakljucena(boolean zakljucena) {
		this.zakljucena = zakljucena;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}